package com.jm3.riscar3.commands;

import com.jm3.riscar3.core.Microcontroller;
import com.jm3.riscar3.helpers.BinaryTranslator;
import com.jm3.riscar3.interfaces.IAR3Command;
import com.jm3.riscar3.memory.Register;

public class STArf implements IAR3Command {

	private final String OpCode = "01011";
	private Register Accumulator;
	private Register[] Registers;
	
	public STArf(Microcontroller mcu)
	{
		this.Accumulator = mcu.getCPU().getAcc();
		this.Registers = mcu.getCPU().getGRegs();
	}
	
	
	@Override
	public void execute(String args) throws Exception {
		// TODO Auto-generated method stub
		
		int regNum = BinaryTranslator.getBitValue(args.substring(0,3));
		Registers[regNum].writeRegister(Accumulator.readRegister());

	}

	@Override
	public String getOpCode() {
		// TODO Auto-generated method stub
		return OpCode;
	}

}
